﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Tools.Client.Library
{
    class ChooseFolderBrowser
    {
        private static readonly Lazy<ChooseFolderBrowser> lazy =
           new Lazy<ChooseFolderBrowser>(() => new ChooseFolderBrowser());
        public static ChooseFolderBrowser Instance { get { return lazy.Value; } }
        private ChooseFolderBrowser() { }

        public string run(string dir)
        {
            dir = dir == "" ? "C:" : dir;
            FolderBrowserDialog fbWnd = new FolderBrowserDialog();
            fbWnd.Description = "选择最终目录";
            fbWnd.SelectedPath = dir;
            fbWnd.ShowNewFolderButton = true;
            string strbtn = fbWnd.ShowDialog().ToString();
            if (strbtn.CompareTo("OK") == 0)
            {
                return fbWnd.SelectedPath;
            }
            return dir;
        }
    }
}
